//package com.zmn.plat.task.job.key;
//
//import com.github.ltsopensource.core.domain.Action;
//import com.github.ltsopensource.core.domain.Job;
//import com.github.ltsopensource.spring.tasktracker.JobRunnerItem;
//import com.github.ltsopensource.spring.tasktracker.LTS;
//import com.github.ltsopensource.tasktracker.Result;
//import com.zmn.common.constant.GlobalConsts;
//import com.zmn.common.dto.ResultDTO;
//import com.zmn.manager.lts.interfaces.task.TaskManager;
//import com.zmn.plat.manager.utils.TaskConsts;
//import com.zmn.plat.services.interfaces.key.KeyService;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//
//import javax.annotation.PostConstruct;
//import javax.annotation.Resource;
//
///**
// * @author duanzuocai
// * @version v1.0
// * @since 2019/1/18 20:52
// */
//@LTS
//public class KeyCreateJob {
//    private Logger logger = LoggerFactory.getLogger(this.getClass());
//
//    @Resource
//    TaskManager taskManager;
//    @Resource
//    KeyService keyService;
//
//    @PostConstruct
//    void init() {
//        Job job = new Job();
//        job.setTaskId(TaskConsts.TASK_ID_KEY_CREATE);
//        job.setParam(TaskManager.SHARD_FIELD, TaskConsts.TASK_ID_KEY_CREATE);
//        job.setCronExpression("0 0 0/1 * * ?");
//        job.setReplaceOnExist(true);
//        ResultDTO result = taskManager.submitTask(job);
//        if (!result.getStatusBool()) {
//            logger.error("#key auto create# job submit fail...");
//        }
//    }
//
//    /**
//     * 描述: 师傅心跳检查维持
//     *
//     * @param job 任务
//     * @return com.github.ltsopensource.tasktracker.Result
//     * @author wangjie
//     * @since 2018/11/28 13:44
//     */
//    @SuppressWarnings("unchecked")
//    @JobRunnerItem(shardValue = TaskConsts.TASK_ID_KEY_CREATE)
//    public Result runKeyCreateJob(Job job) {
//        int num1 = keyService.count(GlobalConsts.KEY_TYPE_BXK);
//        int num2 = keyService.count(GlobalConsts.KEY_TYPE_YHQ);
//
//        if (KeyService.AUTO_CREATE_NUM_CODE > num1) {
//            logger.info("[zmn]-Job: 保修卡随机Code剩余:{}不足:{}个, 开始创建:{}个", num1, KeyService.AUTO_CREATE_NUM_CODE, KeyService.AUTO_CREATE_NUM_JOB);
//            keyService.create(KeyService.AUTO_CREATE_NUM_JOB, GlobalConsts.KEY_TYPE_BXK);
//        }
//        if (KeyService.AUTO_CREATE_NUM_CODE > num2) {
//            logger.info("[zmn]-Job: 优惠券随机Code剩余:{}不足:{}个, 开始创建:{}个", num1, KeyService.AUTO_CREATE_NUM_CODE, KeyService.AUTO_CREATE_NUM_JOB);
//            keyService.create(KeyService.AUTO_CREATE_NUM_JOB, GlobalConsts.KEY_TYPE_YHQ);
//        }
//
//        return new Result(Action.EXECUTE_SUCCESS, "创建随机码");
//    }
//}
